//
//  AppDelegate.m
//  LSUmengShareDemo
//
//  Created by Shawn Li on 15/10/28.
//  Copyright (c) 2015年 Shawn Li. All rights reserved.
//

#import "AppDelegate.h"
#import "LSUmengHeader.h"

@interface AppDelegate ()

@end

@implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.
    
     //设置友盟社会化组件appkey
    //[UMSocialData setAppKey:Umeng_AppKey];
    [LSUmeng umengSetAppKey:Umeng_AppKey];
    //设置微信AppId、appSecret，分享url
    //[UMSocialWechatHandler setWXAppId:Weixin_AppKey appSecret:Weixin_AppSecret url:NotifyUrl];
    [LSUmeng umengSetWXAppId:Weixin_AppKey appSecret:Weixin_AppSecret url:NotifyUrl];
    //设置手机QQ 的AppId，Appkey，和分享URL，需要#import "UMSocialQQHandler.h"
    //[UMSocialQQHandler setQQWithAppId:QQ_AppId appKey:QQ_AppKey url:NotifyUrl];
    [LSUmeng umengSetQQAppId:QQ_AppId appSecret:QQ_AppKey url:NotifyUrl];
    //未安装客户端，允许调用网页验证
    //[UMSocialQQHandler setSupportWebView:YES];
    //[UMSocialSinaHandler openSSOWithRedirectURL:NotifyUrl];
    //打开新浪微博的SSO开关，设置新浪微博回调地址，这里必须要和你在新浪微博后台设置的回调地址一致。若在新浪后台设置我们的回调地址，“http://sns.whalecloud.com/sina2/callback”，这里可以传nil ,需要 #import "UMSocialSinaHandler.h"
    //[UMSocialSinaSSOHandler openNewSinaSSOWithRedirectURL:NotifyUrl];
    [LSUmeng umengOpenNewSinaSSOWithRedirectURL:NotifyUrl];

    return YES;
}

- (void)applicationWillResignActive:(UIApplication *)application {
    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
    // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

- (void)applicationDidEnterBackground:(UIApplication *)application {
    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

- (void)applicationWillEnterForeground:(UIApplication *)application {
    // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

- (void)applicationDidBecomeActive:(UIApplication *)application {
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

- (void)applicationWillTerminate:(UIApplication *)application {
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}

#pragma mark - 实现回调方法

- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url
{
    return  [LSUmeng umengHandleOpenURL:url];
}

//除了使用友盟SDK外，还用了其他SDK，需要重写此回调方法的，可以参考下面的写法
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
    BOOL result = [UMSocialSnsService handleOpenURL:url];
    if (result == FALSE) {
        //调用其他SDK，例如新浪微博SDK等
    }
    return result;
}

@end
